using System;
using System.Text.RegularExpressions;

public static class StringUtils
{
	public static byte[] GetBytes(string str)
	{
		byte[] array = new byte[str.Length * 2];
		Buffer.BlockCopy(str.ToCharArray(), 0, array, 0, array.Length);
		return array;
	}

	public static string GetString(byte[] bytes)
	{
		char[] array = new char[bytes.Length / 2];
		Buffer.BlockCopy(bytes, 0, array, 0, bytes.Length);
		return new string(array);
	}

	public static T ParseEnum<T>(string value) where T : struct, IComparable, IFormattable, IConvertible
	{
		try
		{
			return (T)Enum.Parse(typeof(T), value, ignoreCase: true);
		}
		catch (Exception value2)
		{
			Console.Write(value2);
		}
		return (T)Enum.GetValues(typeof(T)).GetValue(0);
	}

	public static bool IsValidEmail(string email)
	{
		Regex regex = new Regex("^[^@\\s]+@[^@\\s]+(\\.[^@\\s]+)+$");
		Match match = regex.Match(email);
		return match.Success;
	}

	public static bool IsValidPassword(string password)
	{
		return password.Length >= 6 && !password.Contains(" ");
	}
}
